import React, { useEffect, useState } from 'react'

export default function StrictModeCom() {
  //声明一个状态
  let [count, setCount] = useState<number>(0);

  useEffect(() => {
    //启动定时器
    let timer = setInterval(() => {
      //更新状态
      setCount(count => count + 1);
    }, 1000);
    //
    return () => {
      clearInterval(timer);
    }
  }, [])

  return (
    <h2>{count}</h2>
  )
}
